import axios from "axios";
import store from "../store/index"
axios.defaults.baseURL = _Glob.url
axios.defaults.timeout = 10000
axios.interceptors.request.use(
  config => {
    if (store.getters.token) {
      config.headers.Token = store.getters.token.token
    }
    return config
  },
  error => {
    return Promise.error(error);
  })

axios.interceptors.response.use(
  response => {
    if (response.status === 200) {
      return Promise.resolve(response);
    } else {
      return Promise.reject(response);
    }
  },
  // 服务器状态码不是200的情况
  error => {
    return Promise.reject(error.response);
  })

export default axios